﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.OracleClient;
using System.Text;
using ReflectionStudio.Core.Events;
using ReflectionStudio.Core.Helpers;
using System.IO;
using ReflectionStudio.Core;
namespace WPFExcelReport
{
    public partial class INTEXAV95Data
    {
        public DataSet InsertAB05(DataRow dwWDECK, DataRow dwVKPOS, string fEnd, string gStart, string ABKAUFART, string KRS, int LeadTime, string apKRS, string apNum, string ablo, string ablb, string ablp)
        {
            #region============VARIABLE====================
            DataSet setReturn = new DataSet();
            DataSet setResult = new DataSet();
            DataSet setTemp = new DataSet();
            
            DataRow dwLocal = null;
            DataTable tableLocal = null;
            OracleCommand or1;
            string LFD = "000000", POS = "010";
            string ABPART = "", ABPVAR = "", WDPRART = "", WDPRVAR = "";
            string ABPSME = "2"; 
            string ABPNEUBEN = "SUNLV   ";
            string ABPNEUDAT = "20110823", STARTDATE = "20110822", ENDDATE = "20110826";
            string APZALFDNR = " ", APZANRKRS = " ";
            #endregion
            try
            {
                or1 = OracleDB.CreateCommand();
                #region============GETNUMBER======================
                LFD = GetAUFLFD(KRS);
                #endregion
                #region============WASTAMM==================== 
                ABPART = dwWASTAMM["WAART"].ToString();
                ABPVAR = dwWASTAMM["WAVAR"].ToString();
                #endregion

                #region============APZUORD======================
                string APZSTUFE = dwWDECK["WDWAKZ"].ToString();

                APZANRKRS = apKRS;
                APZALFDNR = apNum;
               
                #endregion 
                #region============MAPDATA=========================
                dwLocal = SetData.ABPOS.NewRow();
                ABPNEUBEN = UserID;
                ABPNEUDAT = iDate;
                ENDDATE = dwWDECK["WDDAT"].ToString();
                STARTDATE = GetDateAddDays(ENDDATE, 0 - LeadTime);
                dwLocal["ABPMANDANT"] = dwWDECK["WDMANDANT"].ToString();
                dwLocal["ABPAUFKRS"] = KRS;
                dwLocal["ABPAUFLFD"] = LFD;
                dwLocal["ABPAUFPOS"] = POS;
                dwLocal["ABPZLO"] = ablo;
                dwLocal["ABPZLB"] = ablb;
                dwLocal["ABPBLO"] = ablo;
                dwLocal["ABPAUFART"] = ABKAUFART;
                dwLocal["ABPNEUBEN"] = ABPNEUBEN;
                dwLocal["ABPNEUDAT"] = ABPNEUDAT;
                dwLocal["ABPART"] = dwWASTAMM["WAART"].ToString();
                dwLocal["ABPVAR"] = dwWASTAMM["WAVAR"].ToString(); 
                dwLocal["ABPLAEAENDA"] = 0;
                dwLocal["ABPSTDLAE"] = 20000;
                if (ABKAUFART == "VA")
                {
                    dwLocal["ABPLAEAENDA"] = dwWASTAMM["WALAEAEND"];
                    ABPSME = "2";
                }
                if (ABKAUFART == "DI")
                {
                    dwLocal["ABPSTDLAE"] = dwWASTAMM["WAFSTDLG"];
                    ABPSME = "1";
                } 
                dwLocal["ABPSME"] = ABPSME;
                dwLocal["ABPENDDATA"] = ENDDATE;
                dwLocal["ABPLIEFDAT"] = ENDDATE;
                dwLocal["ABPLIEFDATN"] = ENDDATE;
                dwLocal["ABPENDDAT"] = ENDDATE;
                dwLocal["ABPENDDATA"] = ENDDATE; 
                dwLocal["ABPSTARTDAT"] = STARTDATE;
                dwLocal["ABPSTARTDATA"] = STARTDATE;
                dwLocal["ABPSTARTDATN"] = STARTDATE;
                dwLocal["ABPVTDATE"] = iDate;
                dwLocal["ABPTERMDAT"] = ENDDATE;

                dwLocal["ABPWAKZ"] = dwWDECK["WDWAKZ"].ToString();
                dwLocal["ABPFARBE"] = dwWDECK["WDFARBE"].ToString();
                dwLocal["ABPBESCHICH"] = dwWDECK["WDBESCHICH"].ToString();

                dwLocal["ABPANRKR"] = APZANRKRS;
                dwLocal["ABPALFDNR"] = APZALFDNR;

                double WALAEAEND = System.Convert.ToDouble(dwWASTAMM["WALAEAEND"].ToString());
                double WARWBRT = System.Convert.ToDouble(dwWASTAMM["WARWBRT"].ToString());
                double WAFBRTL = System.Convert.ToDouble(dwWASTAMM["WAFBRTL"].ToString());
                double WARGRLFD = System.Convert.ToDouble(dwWASTAMM["WARGRLFD"].ToString());
                double WAFGRLFD = System.Convert.ToDouble(dwWASTAMM["WAFGRLFD"].ToString());
                double WAFSTDLG = System.Convert.ToDouble(dwWASTAMM["WAFSTDLG"].ToString());
                if (WAFSTDLG == 0)
                {
                    WAFSTDLG = 100000;
                }
                switch (ABPSME)
                {
                    case "1":
                        ABPSOLLMENGE1 = fEnd;
                        ABPSOLLMENGE2 = fEnd;
                        break;
                    case "2":
                        ABPSOLLMENGE2 = fEnd;
                        ABPSOLLMENGE1 =gStart;// System.Math.Round(System.Convert.ToDouble(ABPSOLLMENGE2) / (1 + WALAEAEND * 0.0001,0).ToString();
                        break;
                    default:
                        break;
                }
                ABPSOLLMENGE3 =System.Math.Round(System.Convert.ToDouble(ABPSOLLMENGE1)  * (WARWBRT * 0.001),0).ToString();
                ABPSOLLMENGE4 =System.Math.Round(System.Convert.ToDouble(ABPSOLLMENGE2) * (WAFBRTL * 0.001), 0).ToString();
                ABPSOLLMENGE5 =System.Math.Round(System.Convert.ToDouble(ABPSOLLMENGE1)  * (WARGRLFD * 0.001),0).ToString();
                ABPSOLLMENGE6 =System.Math.Round(System.Convert.ToDouble(ABPSOLLMENGE2)  * (WAFGRLFD * 0.001),0).ToString();
                ABPSOLLMENGE7 ="0";
                ABPSOLLMENGE8 =System.Math.Round(System.Convert.ToDouble(ABPSOLLMENGE2)   / (WAFSTDLG * 0.001),0).ToString();
                
                dwLocal["ABPSOLLMENGE1"] = ABPSOLLMENGE1;
                dwLocal["ABPSOLLMENGE2"] = ABPSOLLMENGE2;
                dwLocal["ABPSOLLMENGE3"] = ABPSOLLMENGE3;
                dwLocal["ABPSOLLMENGE4"] = ABPSOLLMENGE4;
                dwLocal["ABPSOLLMENGE5"] = ABPSOLLMENGE5;
                dwLocal["ABPSOLLMENGE6"] = ABPSOLLMENGE6;
                dwLocal["ABPSOLLMENGE7"] = ABPSOLLMENGE7;
                dwLocal["ABPSOLLMENGE8"] = ABPSOLLMENGE8; 
                dwLocal["ABPAENDBEN"] = ABPNEUBEN;
                dwLocal["ABPAENDDAT"] = ABPNEUDAT;

                #endregion

                #region============INSERT==========================
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "INSERT INTO ABPOS(ABPMANDANT, ABPAUFKRS, ABPAUFLFD, ABPAUFPOS, ABPVFAUFKRS, ABPVFAUFLFD, ABPVFAUFPOS, ABPAUFART, ABPAUFST, ABPAUFSTV, ABPAUFSTB, ABPAUTO, ABPPRIO, ABPTLVF, ABPDIVARTKZ, ABPKUNDNR, ABPWERK, ABPABT, ABPWAKZ, ABPART, ABPVAR, ABPFARBE, ABPDESS, ABPCOLORIT, ABPBESCHICH, ABPGROE, ABPAUFM, ABPVERP, ABPANZVP, ABPFWARTGRA, ABPFWARTGRP, ABPZLO, ABPZLB, ABPBLO, ABPSME, ABPSOLLMENGE1, ABPSOLLMENGE2, ABPSOLLMENGE3, ABPSOLLMENGE4, ABPSOLLMENGE5, ABPSOLLMENGE6, ABPSOLLMENGE7, ABPSOLLMENGE8, ABPRESMGE, ABPRESKG, ABPRESSTK, ABPZUGET, ABPZUGKG, ABPZUGSTK, ABPDILFM, ABPDIKG, ABPDISTK, ABPZTLGKOMP, ABPSMGKZZU, ABPVLLFM, ABPVLKG, ABPVLSTK, ABPEALFM, ABPEAKG, ABPEASTK, ABPEBLFM, ABPEBKG, ABPEBSTK, ABPABLFM, ABPABKG, ABPABSTK, ABPVSLFM, ABPVSKG, ABPVSSTK, ABPRTLFM, ABPRTKG, ABPRTSTK, ABPROHWDAT, ABPKDDAT, ABPWVDAT, ABPLIEFDAT, ABPLRUECK, ABPLRDATE, ABPDLR, ABPVTRUECK, ABPVTDATE, ABPUNKLAR, ABPVERSDAT, ABPFREIDAT, ABPSTARTDAT, ABPENDDAT, ABPSTARTDATA, ABPENDDATA, ABPLTERMAK, ABPBESTDAT, ABPANRKR, ABPALFDNR, ABPAFOLGEV, ABPAFOLGEB, ABPANRKR2, ABPALFDNR2, ABPAFOLGEV2, ABPAFOLGEB2, ABPANRKR3, ABPALFDNR3, ABPAFOLGEV3, ABPAFOLGEB3, ABPANRKR4, ABPALFDNR4, ABPAFOLGEV4, ABPAFOLGEB4, ABPVERSAEND, ABPVERSZL, ABPTLFREIG, ABPTLFMG, ABPFREIGKZ, ABPLMAFOLGE, ABPENDAUFM, ABPZAUFM, ABPLIEFNR, ABPGESSTA, ABPKDSTA, ABPWSSTA, ABPAPSTA, ABPRZSTA, ABPWPSTA, ABPWBSTA, ABPABSTA, ABPERLKZ, ABPERLDAT, ABPBEWKZ, ABPDRKZ1, ABPDRKZ2, ABPDRKZ3, ABPDRKZ4, ABPDRKZ5, ABPDRKZ6, ABPDRKZ7, ABPDRKZ8, ABPDRKZ9, ABPDRKZ10, ABPDR1USER, ABPDR1DAT, ABPDR8USER, ABPDR8DAT, ABPRETOURZL, ABPRPCOUNTAK, ABPURAUFKRS, ABPURAUFLFD, ABPURAUFPOS, ABPASAUFKRS, ABPASAUFLFD, ABPASAUFPOS, ABPREAFOLGE, ABPRWKRS, ABPRWLFD, ABPSTKNRKR, ABPSERIE, ABPAGBKZ, ABPWAART, ABPANZSTK, ABPZUGETGES, ABPSTKKZ, ABPSTKLG, ABPANZSTKR, ABPABZKZ, ABPBDEKZ, ABPSUBSYS, ABPDATBDE, ABPUHRBDE, ABPDISPOKZ, ABPSCHLICHTE, ABPZZUSATZ, ABPZZUSKZ, ABPSZUSTAND, ABPIZUSTAND, ABPSZUSATZKZ1, ABPSZUSATZKZ2, ABPSZUSATZKZ3, ABPSZUSATZKZ4, ABPWERKE, ABPLBMUSTR, ABPFBMUSTR, ABPREAUFKRS, ABPREAUFLFD, ABPREAUFPOS, ABPLTVORL, ABPFDZ, ABPARTEX, ABPLETEILNR, ABPANSNR, ABPUPOS, ABPTP, ABPLBDENR, ABPTMCOUNT, ABPTMCOUNTAK, ABPKDPARTIE, ABPBAHNKZ, ABPGAENGE, ABPZWTWAHL, ABPDIVWLFM, ABPDIVWKG, ABPDISPOST, ABPKETTAUFT, ABPKETTGARN, ABPSPGRD, ABPSPBENID, ABPSPDAT, ABPLMDAT, ABPLMZT, ABPWPLKZ, ABPKKUNDNR, ABPKLAND, ABPKVB, ABPKVG, ABPKPROGRP, ABPKARTGRP, ABPKVKZ, ABPLAEVON, ABPLAEBIS, ABPSTDLAE, ABPMGV, ABPMGB, ABPPAS, ABPPAI, ABPAZUTEIL, ABPZUTART, ABPFA, ABPGA, ABPQA, ABPMAFZST, ABPQPKTH, ABPQPKTLH, ABPSTKNEUTR, ABPREGEL, ABPSTAFFNR, ABPWERKEKZ, ABPWKSTKRS, ABPWKST, ABPWKART, ABPWMNRKRS, ABPWMLFDNR, ABPWMPOS, ABPWMODNR, ABPWINTV, ABPWKENN, ABPWSTOERGRD, ABPWAKSTKRS, ABPWAKST, ABPWPERSNR, ABPWDATV, ABPWZEITV, ABPWDATB, ABPWZEITB, ABPWSTA, ABPFKALK, ABPLIEFDATN, ABPLAEAENDE, ABPLAEAENDA, ABPDMWAKZ, ABPDMART, ABPDMVAR, ABPDMDESS, ABPDMCOLORIT, ABPDMFARBE, ABPDMBESCHICH, ABPDKART, ABPDKVAR, ABPDKFARBE, ABPDKBRUT, ABPGENEHMKZ, ABPSTUEART, ABPCOMPKZ, ABPPOSTYP, ABPORDER, ABPNPGRUND, ABPREWEIL, ABPFSCHL, ABPKSTKRS, ABPKST, ABPMURW, ABPMUVB, ABPMUFW, ABPMUPF, ABPERSTFB, ABPERSTDR, ABPERSTBE, ABPMUCTOD, ABPKDFREI, ABPREZFB, ABPREZDR, ABPPRUEF, ABPNIXWE, ABPCOLSTA, ABPFBSTA, ABPBAHNNR, ABPBAHNBRT, ABPFLBEDECK, ABPDATABDE, ABPUHRABDE, ABPLOEKZ, ABPTERMDAT, ABPPRFI, ABPPRVAR, ABPPRBE, ABPPRZU, ABPPRDESS, ABPZUSATZ1, ABPZUSATZ2, ABPZUSATZ3, ABPZUSATZ4, ABPZUSATZ5, ABPFLAG1, ABPFLAG2, ABPFLAG3, ABPFLAG4, ABPFLAG5, ABPORGMG, ABPDIFFMG, ABPRARTKZ, ABPSTARTDATN, ABPAESTAT, ABPLBAUFKRS, ABPLBAUFLFD, ABPLBAUFPOS, ABPVEAUFTRAG, ABPREGBLOG, ABPREGBDATE, ABPPROJNR, ABPSHADE, ABPSHADEUNCL, ABPLICHTART, ABPLINE, ABPFILLER1, ABPAENDZL, ABPAENDBEN, ABPAENDDAT, ABPNEUBEN, ABPNEUDAT)"
                    + "VALUES (:ABPMANDANT, :ABPAUFKRS, :ABPAUFLFD, :ABPAUFPOS, '  ', '000000', '000', :ABPAUFART, ' ', '0', '0', ' ', '00', '   ', 'N', '00000000', '   ', '   '"
                + ", 'F', '                    ', '   ', '          ', '          ', '          ', '          ', '       ', '  ', '   ', 0, '     ', '  ', '  ', '  ', '  ', '2', 0, 0, 0, 0, 0, 0"
                + ", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ' ', ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '  ', 0, 0, ' ', 0, 0"
                + ", 0, 0, 0, 0, 0, 0, '  ', '      ', '000', '000', '  ', '000000', 0, 0, '  ', '000000', 0, 0, '  ', '000000', 0, 0, ' ', '001', '000', 0, ' ',"
                + "'000', '  ', '  ', '        ', 'TE', '10', '22', '30', '40', '50', '68', '70', ' ', 0, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '        ', '00000000', '        ', '00000000', 0, 0, '  ', '000000', '000', '  '"
                + ", '000000', '000', '000', '  ', '000000', '  ', '  ', ' ', '   ', 0, 0, ' ', 0, 0, ' ', 'N', '  ', 0, 0, ' ', '     ', '          ', ' ', '    ', '    ', 'F', ' ', ' ', ' ', ' ', '   ', '   ', '  ', '000000', '000', '               ', 0"
                + ", '                                                            ', 0, 0, 0, 0, 0, 1, 0, '          ', ' ', 0, 0, 0, 0, ' ', ' ', ' ', '  ', '        ', 0, 0, 0, ' ', '        ', '   ', '   ', '   ', '   ', '   ', ' ', 0, 0, 0, 0, 99999999"
                + ", 0, 0, ' ', ' ', 100, 100, 100, 98, 98, 98, ' ', '00000000', '00', ' ', '  ', '0000', '000000', '  ', '0000', '00', '000', '00', '  ', '               ', '  ', '0000', '        ', 0, 0, 0, 0, '  ', ' '"
                + ", 0, 0, 0, ' ', '                    ', '  ', '          ', '          ', '          ', '          ', '                    ', '  ', '  ', 0, ' ', '   ', ' ', '   ', '    ', '   ', '  ', '   ', '  ', '0000', ' ', ' ', ' ', ' ', ' ', ' ', ' '"
                + ", ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '0', 0, 0, '00000000', '000000', ' ', '0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 0, 0, 0, 0, 0, 0, 0, ' ', '0', ' ', '  ', '000000', '000', '               ', 0"
                + ", 0, '                        ', '   ', ' ', '     ', '   ', '                                                                                                      ', 1, '        ', 0,:ABPNEUBEN, :ABPNEUDAT)";
                or1.Parameters.Add("ABPMANDANT", OracleType.NVarChar).Value = dwLocal["ABPMANDANT"];
                or1.Parameters.Add("ABPAUFKRS", OracleType.NVarChar).Value = dwLocal["ABPAUFKRS"];
                or1.Parameters.Add("ABPAUFLFD", OracleType.NVarChar).Value = dwLocal["ABPAUFLFD"];
                or1.Parameters.Add("ABPAUFPOS", OracleType.NVarChar).Value = dwLocal["ABPAUFPOS"];
                or1.Parameters.Add("ABPAUFART", OracleType.NVarChar).Value = dwLocal["ABPAUFART"];
                or1.Parameters.Add("ABPNEUBEN", OracleType.NVarChar).Value = dwLocal["ABPNEUBEN"];
                or1.Parameters.Add("ABPNEUDAT", OracleType.NVarChar).Value = dwLocal["ABPNEUDAT"];
                setResult = Connect2Proxy(or1);

                #endregion

                #region============UPDATE=========================
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "UPDATE ABPOS SET "
                    + " ABPWAKZ=:ABPWAKZ,ABPART=:ABPART,ABPVAR=:ABPVAR,ABPFARBE=:ABPFARBE,ABPBESCHICH=:ABPBESCHICH"
                    + ",ABPZLO=:ABPZLO,ABPZLB=:ABPZLB,ABPBLO=:ABPBLO"
                    + " ,ABPSME=:ABPSME,ABPSOLLMENGE1=:ABPSOLLMENGE1,ABPSOLLMENGE2=:ABPSOLLMENGE2,ABPSOLLMENGE3=:ABPSOLLMENGE3"
                    + ",ABPSOLLMENGE4=:ABPSOLLMENGE4,ABPSOLLMENGE5=:ABPSOLLMENGE5,ABPSOLLMENGE6=:ABPSOLLMENGE6,ABPSOLLMENGE7=:ABPSOLLMENGE7"
                    + ",ABPSOLLMENGE8=:ABPSOLLMENGE8"
                    + ",ABPSTDLAE=:ABPSTDLAE,ABPLAEAENDA=:ABPLAEAENDA"
                    + ",ABPENDDAT=:ABPENDDAT,ABPENDDATA=:ABPENDDATA,ABPLIEFDAT=:ABPLIEFDAT,ABPLIEFDATN=:ABPLIEFDATN,ABPSTARTDAT=:ABPSTARTDAT,ABPSTARTDATA=:ABPSTARTDATA,ABPVTDATE=:ABPVTDATE,ABPTERMDAT=:ABPTERMDAT"
                    + ",ABPSTARTDATN=:ABPSTARTDATN"
                    + " ,ABPANRKR=:ABPANRKR, ABPALFDNR=:ABPALFDNR"
                    + ",ABPAENDBEN=:ABPAENDBEN,ABPAENDDAT=:ABPAENDDAT"
                    + " WHERE ABPMANDANT=:ABPMANDANT AND ABPAUFKRS=:ABPAUFKRS AND ABPAUFLFD=:ABPAUFLFD AND ABPAUFPOS=:ABPAUFPOS AND ABPAUFART=:ABPAUFART";

                or1.Parameters.Add("ABPMANDANT", OracleType.NVarChar).Value = dwLocal["ABPMANDANT"];
                or1.Parameters.Add("ABPAUFKRS", OracleType.NVarChar).Value = dwLocal["ABPAUFKRS"];
                or1.Parameters.Add("ABPAUFLFD", OracleType.NVarChar).Value = dwLocal["ABPAUFLFD"];
                or1.Parameters.Add("ABPAUFPOS", OracleType.NVarChar).Value = dwLocal["ABPAUFPOS"];
                or1.Parameters.Add("ABPAUFART", OracleType.NVarChar).Value = dwLocal["ABPAUFART"];
                or1.Parameters.Add("ABPWAKZ", OracleType.NVarChar).Value = dwLocal["ABPWAKZ"];
                or1.Parameters.Add("ABPART", OracleType.NVarChar).Value = dwLocal["ABPART"];
                or1.Parameters.Add("ABPVAR", OracleType.NVarChar).Value = dwLocal["ABPVAR"];
                or1.Parameters.Add("ABPFARBE", OracleType.NVarChar).Value = dwLocal["ABPFARBE"];
                or1.Parameters.Add("ABPBESCHICH", OracleType.NVarChar).Value = dwLocal["ABPBESCHICH"];
                or1.Parameters.Add("ABPSME", OracleType.NVarChar).Value = dwLocal["ABPSME"];

                or1.Parameters.Add("ABPZLO", OracleType.NVarChar).Value = dwLocal["ABPZLO"];
                or1.Parameters.Add("ABPZLB", OracleType.NVarChar).Value = dwLocal["ABPZLB"];
                or1.Parameters.Add("ABPBLO", OracleType.NVarChar).Value = dwLocal["ABPBLO"];

                or1.Parameters.Add("ABPSOLLMENGE1", OracleType.NVarChar).Value = dwLocal["ABPSOLLMENGE1"];
                or1.Parameters.Add("ABPSOLLMENGE2", OracleType.NVarChar).Value = dwLocal["ABPSOLLMENGE2"];
                or1.Parameters.Add("ABPSOLLMENGE3", OracleType.NVarChar).Value = dwLocal["ABPSOLLMENGE3"];
                or1.Parameters.Add("ABPSOLLMENGE4", OracleType.NVarChar).Value = dwLocal["ABPSOLLMENGE4"];
                or1.Parameters.Add("ABPSOLLMENGE5", OracleType.NVarChar).Value = dwLocal["ABPSOLLMENGE5"];
                or1.Parameters.Add("ABPSOLLMENGE6", OracleType.NVarChar).Value = dwLocal["ABPSOLLMENGE6"];
                or1.Parameters.Add("ABPSOLLMENGE7", OracleType.NVarChar).Value = dwLocal["ABPSOLLMENGE7"];
                or1.Parameters.Add("ABPSOLLMENGE8", OracleType.NVarChar).Value = dwLocal["ABPSOLLMENGE8"];
                //,ABPENDDAT=:ABPENDDAT,ABPENDDATA=:ABPENDDATA,ABPLIEFDAT=:ABPLIEFDAT,ABPLIEFDATN=:ABPLIEFDATN,ABPSTARTDAT=:ABPSTARTDAT,ABPSTARTDATA=:ABPSTARTDATA,ABPVTDATE=:ABPVTDATE,ABPTERMDAT=:ABPTERMDAT
                or1.Parameters.Add("ABPENDDAT", OracleType.NVarChar).Value = dwLocal["ABPENDDAT"];
                or1.Parameters.Add("ABPENDDATA", OracleType.NVarChar).Value = dwLocal["ABPENDDATA"];
                or1.Parameters.Add("ABPLIEFDAT", OracleType.NVarChar).Value = dwLocal["ABPLIEFDAT"];
                or1.Parameters.Add("ABPLIEFDATN", OracleType.NVarChar).Value = dwLocal["ABPLIEFDATN"];
                or1.Parameters.Add("ABPSTARTDAT", OracleType.NVarChar).Value = dwLocal["ABPSTARTDAT"];
                or1.Parameters.Add("ABPSTARTDATA", OracleType.NVarChar).Value = dwLocal["ABPSTARTDATA"];
                or1.Parameters.Add("ABPSTARTDATN", OracleType.NVarChar).Value = dwLocal["ABPSTARTDATN"];

                or1.Parameters.Add("ABPVTDATE", OracleType.NVarChar).Value = dwLocal["ABPVTDATE"];
                or1.Parameters.Add("ABPTERMDAT", OracleType.NVarChar).Value = dwLocal["ABPTERMDAT"];

                or1.Parameters.Add("ABPANRKR", OracleType.NVarChar).Value = dwLocal["ABPANRKR"];
                or1.Parameters.Add("ABPALFDNR", OracleType.NVarChar).Value = dwLocal["ABPALFDNR"];
                or1.Parameters.Add("ABPSTDLAE", OracleType.NVarChar).Value = dwLocal["ABPSTDLAE"];
                or1.Parameters.Add("ABPLAEAENDA", OracleType.NVarChar).Value = dwLocal["ABPLAEAENDA"];

                or1.Parameters.Add("ABPAENDBEN", OracleType.NVarChar).Value = dwLocal["ABPAENDBEN"];
                or1.Parameters.Add("ABPAENDDAT", OracleType.NVarChar).Value = dwLocal["ABPAENDDAT"];
                setResult = Connect2Proxy(or1);
                #endregion

                #region============SELECT==========================
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT * FROM ABPOS "
                + " WHERE ABPMANDANT=:ABPMANDANT AND ABPAUFKRS=:ABPAUFKRS AND ABPAUFLFD= :ABPAUFLFD AND ABPAUFPOS= :ABPAUFPOS";

                or1.Parameters.Add("ABPMANDANT", OracleType.NVarChar).Value = dwLocal["ABPMANDANT"];
                or1.Parameters.Add("ABPAUFKRS", OracleType.NVarChar).Value = dwLocal["ABPAUFKRS"];
                or1.Parameters.Add("ABPAUFLFD", OracleType.NVarChar).Value = dwLocal["ABPAUFLFD"];
                or1.Parameters.Add("ABPAUFPOS", OracleType.NVarChar).Value = dwLocal["ABPAUFPOS"];
                setResult = Connect2Proxy(or1);
                if (setResult.Tables.Count > 0)
                {
                    setResult.Tables[0].TableName = "ABPOS";
                }
                setReturn.Merge(setResult);
                #endregion
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }

        public DataSet InsertAB05WDECK(DataRow dwABPOS, string gStart)
        {
            DataSet setReturn = new DataSet();
            DataSet setResult = new DataSet();
            OracleCommand or1;
            DataRow dwLocal;
            try
            {
                //SELECT * FROM WDECK WHERE WDAUFKRS='T6'AND WDAUFLFD='005116'AND WDAUFPOS='010'
                #region============MAPDATA=========================
                dwLocal = SetData.WDECK.NewWDECKRow();
                dwLocal["WDMANDANT"] = dwABPOS["ABPMANDANT"];
                dwLocal["WDSA"] = "V";
                dwLocal["WDAUFKRS"] = dwABPOS["ABPAUFKRS"];
                dwLocal["WDAUFLFD"] = dwABPOS["ABPAUFLFD"];
                dwLocal["WDAUFPOS"] = dwABPOS["ABPAUFPOS"];
                dwLocal["WDUPOS"] = "01";
                dwLocal["WDWAKZ"] = dwABPOS["ABPWAKZ"];
                dwLocal["WDART"] = dwABPOS["ABPART"];
                dwLocal["WDVAR"] = dwABPOS["ABPVAR"];
                dwLocal["WDDESS"] = dwABPOS["ABPDESS"];
                dwLocal["WDCOLORIT"] = dwABPOS["ABPCOLORIT"];
                dwLocal["WDFARBE"] = dwABPOS["ABPFARBE"];
                dwLocal["WDBESCHICH"] = dwABPOS["ABPBESCHICH"];
                dwLocal["WDDAT"] = dwABPOS["ABPENDDAT"];
                dwLocal["WDPRART"] = dwWASTAMM["WAVWART"];
                dwLocal["WDPRVAR"] = dwWASTAMM["WAVWVAR"];
                #endregion

                #region============INSERT F========================

                or1 = OracleDB.CreateCommand();
                or1.CommandText = "INSERT INTO WDECK(WDMANDANT, WDSA, WDAUFKRS, WDAUFLFD, WDAUFPOS, WDTYP, WDUPOS, WDKUNDNR, WDWERK, WDABT, WDWAKZ, WDART, WDDESS, WDCOLORIT, WDFARBE, WDBESCHICH, WDVAR, WDZUSTAND, WDDAT, WDLO, WDZS, WDAFOLGE, WDBEDARF, WDZUGET, WDRESERV, WDVERBR, WDANZSTK, WDKZBEDARF, WDURAUFKRS, WDURAUFLFD, WDURAUFPOS, WDVKNPOS, WDPGLKZ, WDABRKZ, WDDISPOKZ, WDERLKZ, WDSLPOS, WDPRART, WDPRVAR, WDBEDBAS, WDLAGE, WDVARFR, WDBEDST, WDFILLER)"
                    + "VALUES (:WDMANDANT, :WDSA, :WDAUFKRS, :WDAUFLFD, :WDAUFPOS, 'Z', :WDUPOS, '00000000', '   ', '   ', ' ', '                    ', '          ', '          ', '          ', '          ', '  ', '    ', '        ', '  ', ' ', '000', 0, 0, 0, 0, '000', ' ', '  ', '000000', '000', 0, ' ', ' ', ' ', ' ', 0, '                    ', '  ', '00000000', '00', ' ', ' ', '000000000      ')";

                or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwLocal["WDMANDANT"];
                or1.Parameters.Add("WDSA", OracleType.NVarChar).Value = dwLocal["WDSA"];
                or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwLocal["WDAUFKRS"];
                or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwLocal["WDAUFLFD"];
                or1.Parameters.Add("WDAUFPOS", OracleType.NVarChar).Value = dwLocal["WDAUFPOS"];
                or1.Parameters.Add("WDUPOS", OracleType.NVarChar).Value = dwLocal["WDUPOS"];

                setResult = Connect2Proxy(or1);

                or1 = OracleDB.CreateCommand();
                or1.CommandText = "UPDATE WDECK SET WDWAKZ=:WDWAKZ "
                    + ",WDART=:WDART,WDDESS=:WDDESS,WDCOLORIT=:WDCOLORIT,WDFARBE=:WDFARBE,WDBESCHICH=:WDBESCHICH,WDVAR=:WDVAR"
                    + ",WDDAT=:WDDAT,WDPRART=:WDPRART,WDPRVAR=:WDPRVAR"
                    + " WHERE WDMANDANT=:WDMANDANT AND WDAUFKRS=:WDAUFKRS AND WDAUFLFD=:WDAUFLFD AND WDAUFPOS=:WDAUFPOS AND WDUPOS=:WDUPOS";

                or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwLocal["WDMANDANT"];
                or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwLocal["WDAUFKRS"];
                or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwLocal["WDAUFLFD"];
                or1.Parameters.Add("WDAUFPOS", OracleType.NVarChar).Value = dwLocal["WDAUFPOS"];
                or1.Parameters.Add("WDUPOS", OracleType.NVarChar).Value = dwLocal["WDUPOS"];
                or1.Parameters.Add("WDWAKZ", OracleType.NVarChar).Value = dwLocal["WDWAKZ"];
                or1.Parameters.Add("WDART", OracleType.NVarChar).Value = dwLocal["WDART"];
                or1.Parameters.Add("WDVAR", OracleType.NVarChar).Value = dwLocal["WDVAR"];
                or1.Parameters.Add("WDDESS", OracleType.NVarChar).Value = dwLocal["WDDESS"];
                or1.Parameters.Add("WDCOLORIT", OracleType.NVarChar).Value = dwLocal["WDCOLORIT"];
                or1.Parameters.Add("WDFARBE", OracleType.NVarChar).Value = dwLocal["WDFARBE"];
                or1.Parameters.Add("WDBESCHICH", OracleType.NVarChar).Value = dwLocal["WDBESCHICH"];
                or1.Parameters.Add("WDDAT", OracleType.NVarChar).Value = dwLocal["WDDAT"];
                or1.Parameters.Add("WDPRART", OracleType.NVarChar).Value = dwLocal["WDPRART"];
                or1.Parameters.Add("WDPRVAR", OracleType.NVarChar).Value = dwLocal["WDPRVAR"];

                setResult = Connect2Proxy(or1);
                #endregion

                #region============INSERT==========================
                or1 = OracleDB.CreateCommand();
                dwLocal["WDUPOS"] = "02";
                or1.CommandText = "INSERT INTO WDECK(WDMANDANT, WDSA, WDAUFKRS, WDAUFLFD, WDAUFPOS, WDTYP, WDUPOS, WDKUNDNR, WDWERK, WDABT, WDWAKZ, WDART, WDDESS, WDCOLORIT, WDFARBE, WDBESCHICH, WDVAR, WDZUSTAND, WDDAT, WDLO, WDZS, WDAFOLGE, WDBEDARF, WDZUGET, WDRESERV, WDVERBR, WDANZSTK, WDKZBEDARF, WDURAUFKRS, WDURAUFLFD, WDURAUFPOS, WDVKNPOS, WDPGLKZ, WDABRKZ, WDDISPOKZ, WDERLKZ, WDSLPOS, WDPRART, WDPRVAR, WDBEDBAS, WDLAGE, WDVARFR, WDBEDST, WDFILLER)"
                    + "VALUES (:WDMANDANT, :WDSA, :WDAUFKRS, :WDAUFLFD, :WDAUFPOS, 'B', :WDUPOS, '00000000', '   ', '   ', ' ', '                    ', '          ', '          ', '          ', '          ', '  ', '    ', '        ', '  ', ' ', '000', 0, 0, 0, 0, '000', ' ', '  ', '000000', '000', 0, ' ', ' ', ' ', ' ', 0, '                    ', '  ', '00000000', '00', 'J', 'M', '000000000      ')";
                or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwLocal["WDMANDANT"];
                or1.Parameters.Add("WDSA", OracleType.NVarChar).Value = dwLocal["WDSA"];
                or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwLocal["WDAUFKRS"];
                or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwLocal["WDAUFLFD"];
                or1.Parameters.Add("WDAUFPOS", OracleType.NVarChar).Value = dwLocal["WDAUFPOS"];
                or1.Parameters.Add("WDUPOS", OracleType.NVarChar).Value = dwLocal["WDUPOS"];

                setResult = Connect2Proxy(or1);
                dwLocal["WDMANDANT"] = dwABPOS["ABPMANDANT"];
                dwLocal["WDSA"] = "V";
                dwLocal["WDAUFKRS"] = dwABPOS["ABPAUFKRS"];
                dwLocal["WDAUFLFD"] = dwABPOS["ABPAUFLFD"];
                dwLocal["WDAUFPOS"] = dwABPOS["ABPAUFPOS"];
                dwLocal["WDUPOS"] = "02";
                dwLocal["WDWAKZ"] = "R";
                dwLocal["WDART"] = dwWASTAMM["WAVWART"];
                dwLocal["WDVAR"] = dwWASTAMM["WAVWVAR"];
                dwLocal["WDDESS"] = dwABPOS["ABPDESS"];
                dwLocal["WDCOLORIT"] = dwABPOS["ABPCOLORIT"];
                dwLocal["WDFARBE"] = dwABPOS["ABPFARBE"];
                dwLocal["WDBESCHICH"] = dwABPOS["ABPBESCHICH"];
                dwLocal["WDDAT"] = dwABPOS["ABPSTARTDAT"];
                dwLocal["WDPRART"] = dwWASTAMM["WAVWART"];
                dwLocal["WDPRVAR"] = dwWASTAMM["WAVWVAR"];
                dwLocal["WDBEDARF"] = dwABPOS["ABPSOLLMENGE1"];

                or1 = OracleDB.CreateCommand();
                or1.CommandText = "UPDATE WDECK SET WDWAKZ=:WDWAKZ "
                    + ",WDART=:WDART,WDDESS=:WDDESS,WDCOLORIT=:WDCOLORIT,WDFARBE=:WDFARBE,WDVAR=:WDVAR"
                    + ",WDDAT=:WDDAT,WDPRART=:WDPRART,WDPRVAR=:WDPRVAR,WDBEDARF=:WDBEDARF"
                    + " WHERE WDMANDANT=:WDMANDANT AND WDAUFKRS=:WDAUFKRS AND WDAUFLFD=:WDAUFLFD AND WDAUFPOS=:WDAUFPOS AND WDUPOS=:WDUPOS";

                or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwLocal["WDMANDANT"];
                or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwLocal["WDAUFKRS"];
                or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwLocal["WDAUFLFD"];
                or1.Parameters.Add("WDAUFPOS", OracleType.NVarChar).Value = dwLocal["WDAUFPOS"];
                or1.Parameters.Add("WDUPOS", OracleType.NVarChar).Value = dwLocal["WDUPOS"];
                or1.Parameters.Add("WDWAKZ", OracleType.NVarChar).Value = dwLocal["WDWAKZ"];
                or1.Parameters.Add("WDART", OracleType.NVarChar).Value = dwLocal["WDART"];
                or1.Parameters.Add("WDVAR", OracleType.NVarChar).Value = dwLocal["WDVAR"];
                or1.Parameters.Add("WDDESS", OracleType.NVarChar).Value = dwLocal["WDDESS"];
                or1.Parameters.Add("WDCOLORIT", OracleType.NVarChar).Value = dwLocal["WDCOLORIT"];
                or1.Parameters.Add("WDFARBE", OracleType.NVarChar).Value = dwLocal["WDFARBE"];
                or1.Parameters.Add("WDDAT", OracleType.NVarChar).Value = dwLocal["WDDAT"];
                or1.Parameters.Add("WDPRART", OracleType.NVarChar).Value = dwLocal["WDPRART"];
                or1.Parameters.Add("WDPRVAR", OracleType.NVarChar).Value = dwLocal["WDPRVAR"];
                or1.Parameters.Add("WDBEDARF", OracleType.NVarChar).Value = dwLocal["WDBEDARF"];

                setResult = Connect2Proxy(or1);
                #endregion

                #region============SELECT==========================
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT * FROM WDECK "
                + " WHERE WDMANDANT=:WDMANDANT AND WDAUFKRS=:WDAUFKRS AND WDAUFLFD= :WDAUFLFD AND WDAUFPOS= :WDAUFPOS";

                or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwLocal["WDMANDANT"];
                or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwLocal["WDAUFKRS"];
                or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwLocal["WDAUFLFD"];
                or1.Parameters.Add("WDAUFPOS", OracleType.NVarChar).Value = dwLocal["WDAUFPOS"];
                setResult = Connect2Proxy(or1);
                if (setResult.Tables.Count > 0)
                {
                    setResult.Tables[0].TableName = "WDECK";
                }
                setReturn.Merge(setResult);
                #endregion

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }
        public DataSet InsertAB05ABAUFM(DataRow dwABPOS, DataRow dwWDECK = null, DataRow dwVKPOS = null)
        {
            DataSet setReturn = new DataSet();
            DataSet setResult = new DataSet();
            OracleCommand or1;
            DataRow dwLocal;
            try
            {
                #region============MAPDATA=========================
                dwLocal = SetData.ABAUFM.NewABAUFMRow();
                dwLocal["ABAMANDANT"] = dwABPOS["ABPMANDANT"];
                dwLocal["ABAAUFTYP"] = "V";
                dwLocal["ABAAUFKRS"] = dwABPOS["ABPAUFKRS"];
                dwLocal["ABAAUFLFD"] = dwABPOS["ABPAUFLFD"];
                dwLocal["ABAAUFPOS"] = dwABPOS["ABPAUFPOS"];
                dwLocal["ABANEUBEN"] = dwABPOS["ABPNEUBEN"];
                dwLocal["ABANEUDAT"] = dwABPOS["ABPNEUDAT"];

                string ABPSME = dwABPOS["ABPSME"].ToString();
                long ABASGESLG = 0, ABASGESGEW = 0;
                string ABALEAPOS = "2", ABASME = "2";
                ABASME = ABPSME;
                switch (ABPSME)
                {
                    case "1":
                        ABASGESLG = System.Convert.ToInt64(dwABPOS["ABPSOLLMENGE1"].ToString()) * 10;
                        break;
                    case "2":
                        ABASGESLG = System.Convert.ToInt64(dwABPOS["ABPSOLLMENGE2"].ToString()) * 10;
                        ABASGESGEW = System.Convert.ToInt64(dwABPOS["ABPSOLLMENGE6"].ToString()) * 10;
                        break;
                    case "3":
                        ABASGESLG = System.Convert.ToInt64(dwABPOS["ABPSOLLMENGE3"].ToString()) * 10;
                        break;
                    case "4":
                        ABASGESLG = System.Convert.ToInt64(dwABPOS["ABPSOLLMENGE4"].ToString()) * 10;
                        break;
                    case "5":
                        ABASGESLG = System.Convert.ToInt64(dwABPOS["ABPSOLLMENGE5"].ToString()) * 10;
                        break;
                    case "6":
                        ABASGESLG = System.Convert.ToInt64(dwABPOS["ABPSOLLMENGE6"].ToString()) * 10;
                        break;
                    case "7":
                        ABASGESLG = System.Convert.ToInt64(dwABPOS["ABPSOLLMENGE7"].ToString()) * 10;
                        break;
                    case "8":
                        ABASGESLG = System.Convert.ToInt64(dwABPOS["ABPSOLLMENGE8"].ToString()) * 10;
                        break;
                    default:
                        break;
                }
                #endregion

                #region============INSERT0001======================
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "INSERT INTO ABAUFM(ABAMANDANT, ABAAUFTYP, ABAAUFKRS, ABAAUFLFD, ABAAUFPOS, ABAAPOS, ABAERLKZ, ABARESMG, ABASANZSTK, ABASSTKLG, ABASSTKLGV, ABASSTKLGB, ABASSTKGEW, ABASSTKGEWV, ABASSTKGEWB, ABASSTKBRT, ABASSTKBRTV, ABASSTKBRTB, ABAIANZSTK, ABAIZENSUR1, ABAIZENSURKZ1, ABAIZENSUR2, ABAIZENSURKZ2, ABAIGESLGZS1, ABAIGESLGZS2, ABASTDPOS, ABASFERTKZ, ABAUEBKZ, ABAUMAILKZ, ABASGESLG, ABASGESGEW, ABASME, ABAFRMG, ABARSTSLG, ABARSTSGEW, ABAMINUSLG, ABAMINUSGEW, ABALEAPOS, ABAPOOL, ABARESFLAG, ABAVKAUFTYP, ABAVKAUFKRS, ABAVKAUFLFD, ABAVKAUFPOS, ABAVKUPOS, ABAVB, ABAVG, ABAZUPRIO, ABASTKNEUTR, ABARESPROG, ABARESBEN, ABARESDAT, ABARESZEIT, ABARVSACHB, ABARKUNDNR, ABARBISDAT, ABAVLVB, ABAVLVG, ABAVLSACHB, ABAVLGEGEN, ABAPRKUNDNR, ABAPRAUFKRS, ABAPRAUFLFD, ABAPRAUFPOS, ABAGENEHM, ABAGSACHB, ABALIEFNR, ABAVSACHB, ABAVSTKNR, ABAVERSWEG, ABAMVERSDAT, ABAWVDAT, ABGENDAT, ABAGENNR, ABAGENNAME, ABAGENWEG, ABAZUSTK, ABAZULG, ABAOPTKZ, ABAMAFZST, ABAPART1, ABAPARTST1, ABAPART2, ABAPARTST2, ABAPART3, ABAPARTST3, ABAPART4, ABAPARTST4, ABAPART5, ABAPARTST5, ABAPART6, ABAPARTST6, ABAPART7, ABAPARTST7, ABAPART8, ABAPARTST8, ABAPART9, ABAPARTST9, ABAPART10, ABAPARTST10, ABASZENSUR, ABASZENSURKZ, ABAKUTLSTK, ABABAHNKZ, ABAWDUPOS, ABABAHNEN, ABATEILKZ, ABAKUNDNRU, ABAWERKU, ABAABTU, ABAARTU, ABAVARU, ABADESSU, ABACOLORITU, ABAFARBEU, ABABESCHU, ABAFARBBEZU, ABAANZ1, ABALAENGE1, ABABREITE1, ABAANZ2, ABALAENGE2, ABABREITE2, ABAANZ3, ABALAENGE3, ABABREITE3, ABAANZ4, ABALAENGE4, ABABREITE4, ABAANZ5, ABALAENGE5, ABABREITE5, ABAVERSDAT, ABAVATYP, ABAANZORG, ABAANZKOP, ABAVERSART, ABASPED, ABALIEFKD, ABAVERSKD, ABAADRSLL, ABAVAKZ, ABALIEFKOMP, ABATEILNR, ABAVDPKZ, ABATPMA, ABABOXMAX, ABABOXANZ, ABALGEBNR, ABANKGEB, ABAIFEUCHTE, ABAKUNDNR, ABASTKNR, ABAPARTIE, ABAPARTIEKZ, ABAKDPARTIE, ABAKDAUFTNR, ABAKDAUFDAT, ABAMAART, ABASTKLFDNR, ABAAUFMSL, ABAZUSAM, ABAPACKTYP, ABATAX, ABAHUELSE, ABAWOBST, ABAWICKL, ABAFDRES, ABAKF, ABANRVERG, ABASTKNRKRS, ABASUFFART, ABATRENNZ, ABALAENGEU, ABALAENGES, ABASCHRITW, ABAFUELLZ, ABAASSCHNIT, ABAETITYP, ABAANZRET, ABAKDETKZ, ABADOPPEL, ABALOAN, ABALBAN, ABALPAN, ABAAUFBKZAN, ABALOA2, ABALBA2, ABALPA2, ABAABKZA2, ABAPKL, ABABEM1, ABABEM2, ABAMRKM1, ABAMRKM2, ABAMRKM3, ABAKZNTO, ABAFESP, ABADIAUFKRS, ABADIAUFLFD, ABADIAUFPOS, ABADILG, ABADIGEW, ABADISTK, ABADISLG, ABADISGEW, ABABA, ABAASGESLG, ABAASGESGEW, ABAPNRKRS, ABAPLFDNR, ABAGKREGEL, ABAPROVOR, ABAPRSFE, ABAWSCHTXT, ABAVORSGEL, ABASELVL, ABASELVR, ABAKOLL, ABAVKART, ABAVKFARBE, ABAGBEDKZ, ABADL, ABAKDPARTKZ, ABAFILLER, ABAAENDZL, ABAAENDBEN, ABAAENDDAT, ABANEUBEN, ABANEUDAT)"
                    + "VALUES (:ABAMANDANT, :ABAAUFTYP, :ABAAUFKRS, :ABAAUFLFD, :ABAAUFPOS, '0001', ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ' ', ' ', ' ', ' ', 0, 0, 1, ' ', ' ', ' '"
                + ", 0, 0, ' ', 0, 0, 0, 0, 0, 0, ' ', ' ', ' ', '  ', '000000', '000', '00', '   ', '   ', '9', ' ', '        ', '        ', 0, 0, '        ', '        ', 0, '   ', '   ', '        ', ' ', '        ', '  ', '000000', '000', ' ', '        ', '        ', '        ', '            ', '  ', 0, 0, 0, '            ', '                              ', '  ', 0, 0, ' ', 0, '           ', 0, '           ', 0, '           ', 0, '           ', 0, '           ', 0, '           ', 0, '           ', 0, '           ', 0, '           ', 0, '           ', 0, ' ', ' ', 0, ' ', 1, 0, ' ', '        ', '   ', '   ', '                    ', '   ', '          ', '          ', '          ', '          ', '                    ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '  ', 0, 0, '   ', '   ', '        ', '        ', '        ', 'J', ' ', 0, ' ', '    ', 0, 0, '        ', '  ', 0, '00000000', '            ', '0000000', ' ', '          ', '                    ', 0, ' ', 0, '  ', '  ', '    ', '   ', '      ', ' ', ' ', ' ', ' ', ' ', '  ', ' ', ' ', 0, 0, 0, ' ', 'N', '  ', 0, ' ', '          ', '  ', '  ', '        ', ' ', '  ', '  ', '        ', ' ', '  ', '                                                            ', '                                                            ', '    ', '    ', '    ', ' ', ' ', '  ', '000000', '000', 0, 0, 0, 0, 0, '      ', 0, 0, '  ', '000000', '00000000', '        ', 0, '   ', ' ', 0, 0, '     ', '                        ', '          ', ' ', ' ', ' ', '                                                                                    ', 1, '        ', 0"
                + ", :ABANEUBEN, :ABANEUDAT)";
                or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwLocal["ABAMANDANT"];
                or1.Parameters.Add("ABAAUFTYP", OracleType.NVarChar).Value = dwLocal["ABAAUFTYP"];
                or1.Parameters.Add("ABAAUFKRS", OracleType.NVarChar).Value = dwLocal["ABAAUFKRS"];
                or1.Parameters.Add("ABAAUFLFD", OracleType.NVarChar).Value = dwLocal["ABAAUFLFD"];
                or1.Parameters.Add("ABAAUFPOS", OracleType.NVarChar).Value = dwLocal["ABAAUFPOS"];
                or1.Parameters.Add("ABANEUBEN", OracleType.NVarChar).Value = dwLocal["ABANEUBEN"];
                or1.Parameters.Add("ABANEUDAT", OracleType.NVarChar).Value = dwLocal["ABANEUDAT"];
                setResult = Connect2Proxy(or1);
                #region============UPDATE0001======================
                or1 = OracleDB.CreateCommand();

                or1.CommandText = "UPDATE ABAUFM SET "
                    + "ABASGESLG=:ABASGESLG,ABASME=:ABASME,ABALEAPOS=:ABALEAPOS,ABASGESGEW=:ABASGESGEW"
                + " WHERE ABAMANDANT=:ABAMANDANT AND ABAAUFTYP=:ABAAUFTYP AND ABAAUFKRS=:ABAAUFKRS AND ABAAUFLFD=:ABAAUFLFD AND ABAAUFPOS=:ABAAUFPOS AND ABAAPOS=:ABAAPOS";
                or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwLocal["ABAMANDANT"];
                or1.Parameters.Add("ABAAUFTYP", OracleType.NVarChar).Value = dwLocal["ABAAUFTYP"];
                or1.Parameters.Add("ABAAUFKRS", OracleType.NVarChar).Value = dwLocal["ABAAUFKRS"];
                or1.Parameters.Add("ABAAUFLFD", OracleType.NVarChar).Value = dwLocal["ABAAUFLFD"];
                or1.Parameters.Add("ABAAUFPOS", OracleType.NVarChar).Value = dwLocal["ABAAUFPOS"];
                or1.Parameters.Add("ABAAPOS", OracleType.NVarChar).Value = "0001";
                or1.Parameters.Add("ABASGESLG", OracleType.NVarChar).Value = ABASGESLG;
                or1.Parameters.Add("ABASGESGEW", OracleType.NVarChar).Value = ABASGESGEW;

                or1.Parameters.Add("ABASME", OracleType.NVarChar).Value = ABASME;
                or1.Parameters.Add("ABALEAPOS", OracleType.NVarChar).Value = ABALEAPOS;

                setResult = Connect2Proxy(or1);
                #endregion
                #endregion

                #region============INSERT0002======================
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "INSERT INTO ABAUFM(ABAMANDANT, ABAAUFTYP, ABAAUFKRS, ABAAUFLFD, ABAAUFPOS, ABAAPOS, ABAERLKZ, ABARESMG, ABASANZSTK, ABASSTKLG, ABASSTKLGV, ABASSTKLGB, ABASSTKGEW, ABASSTKGEWV, ABASSTKGEWB, ABASSTKBRT, ABASSTKBRTV, ABASSTKBRTB, ABAIANZSTK, ABAIZENSUR1, ABAIZENSURKZ1, ABAIZENSUR2, ABAIZENSURKZ2, ABAIGESLGZS1, ABAIGESLGZS2, ABASTDPOS, ABASFERTKZ, ABAUEBKZ, ABAUMAILKZ, ABASGESLG, ABASGESGEW, ABASME, ABAFRMG, ABARSTSLG, ABARSTSGEW, ABAMINUSLG, ABAMINUSGEW, ABALEAPOS, ABAPOOL, ABARESFLAG, ABAVKAUFTYP, ABAVKAUFKRS, ABAVKAUFLFD, ABAVKAUFPOS, ABAVKUPOS, ABAVB, ABAVG, ABAZUPRIO, ABASTKNEUTR, ABARESPROG, ABARESBEN, ABARESDAT, ABARESZEIT, ABARVSACHB, ABARKUNDNR, ABARBISDAT, ABAVLVB, ABAVLVG, ABAVLSACHB, ABAVLGEGEN, ABAPRKUNDNR, ABAPRAUFKRS, ABAPRAUFLFD, ABAPRAUFPOS, ABAGENEHM, ABAGSACHB, ABALIEFNR, ABAVSACHB, ABAVSTKNR, ABAVERSWEG, ABAMVERSDAT, ABAWVDAT, ABGENDAT, ABAGENNR, ABAGENNAME, ABAGENWEG, ABAZUSTK, ABAZULG, ABAOPTKZ, ABAMAFZST, ABAPART1, ABAPARTST1, ABAPART2, ABAPARTST2, ABAPART3, ABAPARTST3, ABAPART4, ABAPARTST4, ABAPART5, ABAPARTST5, ABAPART6, ABAPARTST6, ABAPART7, ABAPARTST7, ABAPART8, ABAPARTST8, ABAPART9, ABAPARTST9, ABAPART10, ABAPARTST10, ABASZENSUR, ABASZENSURKZ, ABAKUTLSTK, ABABAHNKZ, ABAWDUPOS, ABABAHNEN, ABATEILKZ, ABAKUNDNRU, ABAWERKU, ABAABTU, ABAARTU, ABAVARU, ABADESSU, ABACOLORITU, ABAFARBEU, ABABESCHU, ABAFARBBEZU, ABAANZ1, ABALAENGE1, ABABREITE1, ABAANZ2, ABALAENGE2, ABABREITE2, ABAANZ3, ABALAENGE3, ABABREITE3, ABAANZ4, ABALAENGE4, ABABREITE4, ABAANZ5, ABALAENGE5, ABABREITE5, ABAVERSDAT, ABAVATYP, ABAANZORG, ABAANZKOP, ABAVERSART, ABASPED, ABALIEFKD, ABAVERSKD, ABAADRSLL, ABAVAKZ, ABALIEFKOMP, ABATEILNR, ABAVDPKZ, ABATPMA, ABABOXMAX, ABABOXANZ, ABALGEBNR, ABANKGEB, ABAIFEUCHTE, ABAKUNDNR, ABASTKNR, ABAPARTIE, ABAPARTIEKZ, ABAKDPARTIE, ABAKDAUFTNR, ABAKDAUFDAT, ABAMAART, ABASTKLFDNR, ABAAUFMSL, ABAZUSAM, ABAPACKTYP, ABATAX, ABAHUELSE, ABAWOBST, ABAWICKL, ABAFDRES, ABAKF, ABANRVERG, ABASTKNRKRS, ABASUFFART, ABATRENNZ, ABALAENGEU, ABALAENGES, ABASCHRITW, ABAFUELLZ, ABAASSCHNIT, ABAETITYP, ABAANZRET, ABAKDETKZ, ABADOPPEL, ABALOAN, ABALBAN, ABALPAN, ABAAUFBKZAN, ABALOA2, ABALBA2, ABALPA2, ABAABKZA2, ABAPKL, ABABEM1, ABABEM2, ABAMRKM1, ABAMRKM2, ABAMRKM3, ABAKZNTO, ABAFESP, ABADIAUFKRS, ABADIAUFLFD, ABADIAUFPOS, ABADILG, ABADIGEW, ABADISTK, ABADISLG, ABADISGEW, ABABA, ABAASGESLG, ABAASGESGEW, ABAPNRKRS, ABAPLFDNR, ABAGKREGEL, ABAPROVOR, ABAPRSFE, ABAWSCHTXT, ABAVORSGEL, ABASELVL, ABASELVR, ABAKOLL, ABAVKART, ABAVKFARBE, ABAGBEDKZ, ABADL, ABAKDPARTKZ, ABAFILLER, ABAAENDZL, ABAAENDBEN, ABAAENDDAT, ABANEUBEN, ABANEUDAT)"
                    + "VALUES (:ABAMANDANT, :ABAAUFTYP, :ABAAUFKRS, :ABAAUFLFD, :ABAAUFPOS,'0002', ' ', 0"
                + ", 0, 0, 100, 9999000, 0, 0, 0, 0, 0, 0, 0, ' ', ' ', ' ', ' ', 0, 0, 1, ' ', ' ', ' ', 0, 0, ' ', 0, 0, 0, 0, 0, 0, ' ', ' '"
                + ", ' ', '  ', '      ', '   ', '  ', '   ', '   ', '7', ' ', '        ', '        ', 0, 0, '        ', '        ', 0, '   ', '   ', '        ', ' ', '        '"
                + ", '  ', '      ', '   ', ' ', '        ', '        ', '        ', '            ', '  ', 0, 0, 0, '            ', '                              ', '  ', 0, 0, ' ', 0, '           ', 0, '           ', 0, '           ', 0"
                + ", '           ', 0, '           ', 0, '           ', 0, '           ', 0, '           ', 0, '           ', 0, '           ', 0, '1', 'A', 0, ' ', 1, 0, ' ', '        ', '   ', '   ', '                    ', '   ', '          ', '          '"
                + ", '          ', '          ', '                    ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '  ', 0, 0, '   ', '   ', '        ', '        ', '        ', ' ', ' ', 0, ' ', '    ', 0, 0, '        ', '  ', 0, '00000000'"
                + ", '            ', '0000000', ' ', '          ', '                    ', 0, ' ', 0, '  ', '  ', '    ', '   ', '      ', 'I', ' ', ' ', ' ', ' ', '  ', ' ', ' ', 0, 0, 0, ' ', ' ', '  ', 0, ' ', '          ', '  ', '  ', '        ', ' ', '  ', '  ', '        ', ' '"
                + ", '  ', '                                                            ', '                                                            ', '    ', '    ', '    ', ' ', ' ', '  ', '000000', '000', 0, 0, 0, 0, 0, '      ', 0, 0, '  ', '000000'"
                + ", '00000000', '        ', 0, '   ', ' ', 0, 0, '     ', '                        ', '          ', ' ', ' ', ' ', '                                                                                    ', 0, '        ', 0"
                + ", :ABANEUBEN, :ABANEUDAT)";
                or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwLocal["ABAMANDANT"];
                or1.Parameters.Add("ABAAUFTYP", OracleType.NVarChar).Value = dwLocal["ABAAUFTYP"];
                or1.Parameters.Add("ABAAUFKRS", OracleType.NVarChar).Value = dwLocal["ABAAUFKRS"];
                or1.Parameters.Add("ABAAUFLFD", OracleType.NVarChar).Value = dwLocal["ABAAUFLFD"];
                or1.Parameters.Add("ABAAUFPOS", OracleType.NVarChar).Value = dwLocal["ABAAUFPOS"];
                or1.Parameters.Add("ABANEUBEN", OracleType.NVarChar).Value = dwLocal["ABANEUBEN"];
                or1.Parameters.Add("ABANEUDAT", OracleType.NVarChar).Value = dwLocal["ABANEUDAT"];
                setResult = Connect2Proxy(or1);


                #region============UPDATE0002======================

                //ABASANZSTK=18	ABASSTKLG=120000
                //ABAVKAUFTYP=K	ABAVKAUFKRS=10	ABAVKAUFLFD=2010	ABAVKAUFPOS=4	ABAVKUPOS=1	ABAVB=119
                //ABARVSACHB=FZ10	ABARKUNDNR=3033
                //ABAVLVB=119 ABAVLSACHB=FZ10
                //ABAPRKUNDNR=3033	ABAPRAUFKRS=10	ABAPRAUFLFD=2010	ABAPRAUFPOS=4
                //ABAVERSDAT=20110923
                double VKPLAEBIS = System.Convert.ToDouble(dwVKPOS["VKPLAEBIS"].ToString()) * 10;
                if (VKPLAEBIS == 0)
                    VKPLAEBIS = 1;
                double ABASANZSTK = System.Math.Round(System.Convert.ToDouble(ABASGESLG) / VKPLAEBIS, 0);
                dwLocal["ABASANZSTK"] = System.Math.Round(ABASANZSTK, 0);
                dwLocal["ABASSTKLG"] = VKPLAEBIS;
                dwLocal["ABAVKAUFTYP"] = dwWDECK["WDSA"];
                dwLocal["ABAVKAUFKRS"] = dwWDECK["WDAUFKRS"];
                dwLocal["ABAVKAUFLFD"] = dwWDECK["WDAUFLFD"];
                dwLocal["ABAVKAUFPOS"] = dwWDECK["WDAUFPOS"];
                dwLocal["ABAVKUPOS"] = "01";

                dwLocal["ABAVB"] = dwVKPOS["VKPVB"];
                dwLocal["ABARVSACHB"] = dwVKPOS["VKPDSACHB"];
                dwLocal["ABARKUNDNR"] = dwVKPOS["VKPKUNDNR"];
                dwLocal["ABAVLVB"] = dwVKPOS["VKPVB"];
                dwLocal["ABAVLSACHB"] = dwVKPOS["VKPSACHBE"];
                dwLocal["ABAPRKUNDNR"] = dwVKPOS["VKPKUNDNR"];
                dwLocal["ABAPRAUFKRS"] = dwWDECK["WDAUFKRS"];
                dwLocal["ABAPRAUFLFD"] = dwWDECK["WDAUFLFD"];
                dwLocal["ABAPRAUFPOS"] = dwWDECK["WDAUFPOS"];
                dwLocal["ABAVERSDAT"] = dwWDECK["WDDAT"];
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "UPDATE ABAUFM SET "
                    + " ABASANZSTK=:ABASANZSTK,ABASSTKLG=:ABASSTKLG,ABAVKAUFTYP=:ABAVKAUFTYP,ABAVKAUFKRS=:ABAVKAUFKRS,ABAVKAUFLFD=:ABAVKAUFLFD,ABAVKAUFPOS=:ABAVKAUFPOS "
                    + ",ABAVKUPOS=:ABAVKUPOS,ABAVB=:ABAVB,ABAVLSACHB=:ABAVLSACHB,ABAPRKUNDNR=:ABAPRKUNDNR,ABAPRAUFKRS=:ABAPRAUFKRS,ABAPRAUFLFD=:ABAPRAUFLFD,ABAPRAUFPOS=:ABAPRAUFPOS,ABAVERSDAT=:ABAVERSDAT"
                    + ",ABARVSACHB=:ABARVSACHB,ABARKUNDNR=:ABARKUNDNR,ABAVLVB=:ABAVLVB"
                + " WHERE ABAMANDANT=:ABAMANDANT AND ABAAUFTYP=:ABAAUFTYP AND ABAAUFKRS=:ABAAUFKRS AND ABAAUFLFD=:ABAAUFLFD AND ABAAUFPOS=:ABAAUFPOS AND ABAAPOS=:ABAAPOS";
                or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwLocal["ABAMANDANT"];
                or1.Parameters.Add("ABAAUFTYP", OracleType.NVarChar).Value = dwLocal["ABAAUFTYP"];
                or1.Parameters.Add("ABAAUFKRS", OracleType.NVarChar).Value = dwLocal["ABAAUFKRS"];
                or1.Parameters.Add("ABAAUFLFD", OracleType.NVarChar).Value = dwLocal["ABAAUFLFD"];
                or1.Parameters.Add("ABAAUFPOS", OracleType.NVarChar).Value = dwLocal["ABAAUFPOS"];
                or1.Parameters.Add("ABAAPOS", OracleType.NVarChar).Value = "0002";
                or1.Parameters.Add("ABASANZSTK", OracleType.NVarChar).Value = dwLocal["ABASANZSTK"];
                or1.Parameters.Add("ABASSTKLG", OracleType.NVarChar).Value = dwLocal["ABASSTKLG"];
                or1.Parameters.Add("ABAVKAUFTYP", OracleType.NVarChar).Value = dwLocal["ABAVKAUFTYP"];
                or1.Parameters.Add("ABAVKAUFKRS", OracleType.NVarChar).Value = dwLocal["ABAVKAUFKRS"];
                or1.Parameters.Add("ABAVKAUFLFD", OracleType.NVarChar).Value = dwLocal["ABAVKAUFLFD"];
                or1.Parameters.Add("ABAVKAUFPOS", OracleType.NVarChar).Value = dwLocal["ABAVKAUFPOS"];
                or1.Parameters.Add("ABAVKUPOS", OracleType.NVarChar).Value = dwLocal["ABAVKUPOS"];
                or1.Parameters.Add("ABAVB", OracleType.NVarChar).Value = dwLocal["ABAVB"];
                or1.Parameters.Add("ABAVLSACHB", OracleType.NVarChar).Value = dwLocal["ABAVLSACHB"];
                or1.Parameters.Add("ABAPRKUNDNR", OracleType.NVarChar).Value = dwLocal["ABAPRKUNDNR"];
                or1.Parameters.Add("ABAVLVB", OracleType.NVarChar).Value = dwLocal["ABAVLVB"];

                or1.Parameters.Add("ABARVSACHB", OracleType.NVarChar).Value = dwLocal["ABARVSACHB"];
                or1.Parameters.Add("ABARKUNDNR", OracleType.NVarChar).Value = dwLocal["ABARKUNDNR"];

                or1.Parameters.Add("ABAPRAUFKRS", OracleType.NVarChar).Value = dwLocal["ABAPRAUFKRS"];
                or1.Parameters.Add("ABAPRAUFLFD", OracleType.NVarChar).Value = dwLocal["ABAPRAUFLFD"];
                or1.Parameters.Add("ABAPRAUFPOS", OracleType.NVarChar).Value = dwLocal["ABAPRAUFPOS"];
                or1.Parameters.Add("ABAVERSDAT", OracleType.NVarChar).Value = dwLocal["ABAVERSDAT"];
                setResult = Connect2Proxy(or1);
                #endregion
                #region============UPDATEVKPOS======================
                /*
                 * VKPPRODST	VKPRESERV	VKPRESERVT1	VKPRESERVT2	VKPRESERVT3	VKPRESERVT4
O	0	0	0	0	0
M	209974	1600	192000	303360	30144
                 */
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "UPDATE VKPOS SET "
                    + " VKPPRODST=:VKPPRODST,VKPRESERV=:VKPRESERV,VKPRESERVT1=:VKPRESERVT1,VKPRESERVT2=:VKPRESERVT2,VKPRESERVT3=:VKPRESERVT3,VKPRESERVT4=:VKPRESERVT4"
                    + " WHERE VKPMANDANT=:VKPMANDANT AND VKPAUFKRS=:VKPAUFKRS AND VKPAUFLFD=:VKPAUFLFD AND VKPAUFPOS=:VKPAUFPOS AND VKPSA='  '";
                or1.Parameters.Add("VKPMANDANT", OracleType.NVarChar).Value = dwVKPOS["VKPMANDANT"];
                or1.Parameters.Add("VKPAUFKRS", OracleType.NVarChar).Value = dwVKPOS["VKPAUFKRS"];
                or1.Parameters.Add("VKPAUFLFD", OracleType.NVarChar).Value = dwVKPOS["VKPAUFLFD"];
                or1.Parameters.Add("VKPAUFPOS", OracleType.NVarChar).Value = dwVKPOS["VKPAUFPOS"];

                or1.Parameters.Add("VKPPRODST", OracleType.NVarChar).Value = "M";
                long ABASSTKLG = System.Convert.ToInt64(dwLocal["ABASSTKLG"]);
                or1.Parameters.Add("VKPRESERV", OracleType.NVarChar).Value = System.Math.Round(ABASANZSTK * ABASSTKLG * 0.1 / 0.9144);
                or1.Parameters.Add("VKPRESERVT1", OracleType.NVarChar).Value = ABASANZSTK * 100;
                or1.Parameters.Add("VKPRESERVT2", OracleType.NVarChar).Value = System.Math.Round(ABASANZSTK * ABASSTKLG * 0.1);
                or1.Parameters.Add("VKPRESERVT3", OracleType.NVarChar).Value = dwABPOS["ABPSOLLMENGE4"];
                or1.Parameters.Add("VKPRESERVT4", OracleType.NVarChar).Value = dwABPOS["ABPSOLLMENGE6"];
                Connect2Proxy(or1);
                #endregion
                #endregion

                #region============SELECT==========================
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT * FROM ABAUFM "
                + " WHERE ABAMANDANT=:ABAMANDANT AND ABAAUFKRS=:ABAAUFKRS AND ABAAUFLFD= :ABAAUFLFD AND ABAAUFPOS= :ABAAUFPOS";

                or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwLocal["ABAMANDANT"];
                or1.Parameters.Add("ABAAUFKRS", OracleType.NVarChar).Value = dwLocal["ABAAUFKRS"];
                or1.Parameters.Add("ABAAUFLFD", OracleType.NVarChar).Value = dwLocal["ABAAUFLFD"];
                or1.Parameters.Add("ABAAUFPOS", OracleType.NVarChar).Value = dwLocal["ABAAUFPOS"];
                setResult = Connect2Proxy(or1);
                if (setResult.Tables.Count > 0)
                {
                    setResult.Tables[0].TableName = "ABAUFM";
                }
                setReturn.Merge(setResult);
                #endregion
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }
        public DataSet ExecuteInsertAB05(DataRow dwWDECK, DataRow dwVKPOS, string fFend,string gStart, string ABKAUFART)
        {
            DataSet setReturn = new DataSet();
            DataSet setResult = new DataSet();
       
            try
            {
                string KRS = "T6";
                DataRow dwFlow = null;
                string stage = "F", art = "", var = "", color = "", matchid = "", finish = "";
                string abplo = "01", abplb = "01", abplp = "010101";
                int LeadTime = 3;
                string sKRS = "", sLFD = "", sPOS = "";
                string apKRS, apNum;
                stage = "F";
                art=dwWASTAMM["WAART"].ToString();
                var = dwWASTAMM["WAVAR"].ToString();
                color = dwColor["WAFZUSATZ"].ToString();
                finish = dwFinish["WAFZUSATZ"].ToString();
                matchid = finish.Trim();
                dwFlow = GetProcessFlow(stage, art, var, color, matchid);
                if (dwFlow == null)
                    return setReturn;
                KRS = dwFlow["ABKKRS"].ToString();
                sKRS=dwFlow["ABKRS"].ToString();
                sLFD=dwFlow["ABLFD"].ToString();
                sPOS=dwFlow["ABPOS"].ToString();
                apKRS = dwFlow["APKRS"].ToString();
                apNum = dwFlow["APNR"].ToString();
                abplo = dwFlow["ABLO"].ToString();
                abplb = dwFlow["ABLB"].ToString();
                abplp = dwFlow["ABLP"].ToString();
                LeadTime = System.Convert.ToInt16(dwFlow["LEADTIME"].ToString());
                #region============ABPOS======================
                EventDispatcher.Instance.RaiseStatus("开始创建ABPOS", StatusEventType.RunningProgress);
                setResult = InsertAB05(dwWDECK, dwVKPOS, fFend, gStart, "VA", KRS, LeadTime,apKRS,apNum,abplo,abplb,abplp);
                setReturn.Merge(setResult);
                #endregion
                dwAB05 = setReturn.Tables["ABPOS"].Rows[0];
                #region============ABKOPF=====================
                EventDispatcher.Instance.RaiseStatus("开始创建ABKOPF", StatusEventType.RunningProgress);
                setResult = InsertABKOPF(dwAB05, ABKAUFART);
                setReturn.Merge(setResult);
                #endregion

                #region============ABPR=======================
                EventDispatcher.Instance.RaiseStatus("开始创建ABPR", StatusEventType.RunningProgress);
                setResult = InsertABPR(dwAB05);
                setReturn.Merge(setResult);
                #endregion

                #region============ABFOLGE====================
                //MATCHID	STAGE	APKRS	APNR	ABKRS	ABLFD	ABPOS	ABKKRS	LEADTIME                
                EventDispatcher.Instance.RaiseStatus("开始创建ABFOLGE", StatusEventType.RunningProgress);
                setResult = InsertABFOLGE(dwAB05,sKRS,sLFD,sPOS);
                setReturn.Merge(setResult);
                #endregion

                #region============ABAUFM=====================
                EventDispatcher.Instance.RaiseStatus("开始创建ABAUFM", StatusEventType.RunningProgress);
                setResult = InsertAB05ABAUFM(dwAB05, dwWDECK, dwVKPOS);
                setReturn.Merge(setResult);
                #endregion

                #region============WDECK=====================
                EventDispatcher.Instance.RaiseStatus("开始创建WDECK", StatusEventType.RunningProgress);
                setResult = InsertAB05WDECK(dwAB05, gStart);
                setReturn.Merge(setResult);
                #endregion
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }
        
    }
}